#pragma once
#include "../../include/types.h"
#include "../proc/spinlock.h"

struct file;
#define PIPESIZE 512

struct pipe {
    spinlock lock;
    char data[PIPESIZE];
    uint32 nread;     // number of bytes read
    uint32 nwrite;    // number of bytes written
    int readopen;   // read fd is still open
    int writeopen;  // write fd is still open
  };

  int
  pipealloc(struct file **f0, struct file **f1);

  void
  pipeclose(struct pipe *pi, int writable);

  int
  pipewrite(struct pipe *pi, uint64 addr, int n);

  int
  piperead(struct pipe *pi, uint64 addr, int n);